﻿#pragma once

#include <QWidget>
#include <QObject>


#include <QWidget>
#include <QLabel>
#include <QTextBrowser>
#include <QLayout>
#include <QTextCodec>
#include <QDebug>
#include <QTreeWidget>
#include <QTreeWidgetItem>


#define COPY_OK 0
#define COPY_SKIP -1 //用户跳过
#define COPY_ERROR -2 //api出错

class QDockWidget;
class QPushButton;
class QLineEdit;
class QListView;
class QTreeView;
class MFileSystemModel;
class QAbstractItemView;
class FHistoryStack;
class MultiSearchClass : public QObject
{
	Q_OBJECT

public:
	explicit MultiSearchClass(QWidget* parent);;
	~MultiSearchClass();

public:
    enum ViewType { Icon, Detail };
    Q_ENUM(ViewType)

private slots:
	void on_pluginViewShow();
    void on_OpenDirShow();

private:
    QPushButton* m_backButton;
    QPushButton* m_forwardButton;
    QPushButton* m_upButton;
    QLineEdit* m_urlEdit;
    QPushButton* m_enterButton;
    QListView* m_listView;
    QTreeView* m_treeView;  //QListView不支持header,无法提供详细信息。根据API：This view does not display horizontal or vertical headers;
//to display a list of items with a horizontal header, use QTreeView instead.

    MFileSystemModel* m_fileModel;
    QString m_currPath;
    ViewType m_currType;
    QDockWidget* dockWidget_;
    QWidget* mainWidget_;
    FHistoryStack* m_historyStack;
    QWidget* centralWidget;

private:
    void initWidget();
    bool inMyComputer() const;
    bool inNetwork() const;
    void jumpToMyComputer();
    bool jumpTo(const QString& path);
    QAbstractItemView* getCurrentView();

public :
    int CopySingleFile(const QString& src, const QString& dst, bool move);
    ///Focus: dst is destination dir path (targetDir/)
    int CopyDir(const QString& src, const QString& dst, bool move);
    ///Focus: support muti object which must has the same parent folder
    bool openShellContextMenu(const QStringList& pathList);
    void onLineEditEnter();
    void onUpButtonClick();
    void onBackButtonEnable(bool);
    void onForwardButtonEnable(bool);
    void onBackButtonClick();
    void onForwardButtonClick();
    void onItemDoubleClick(const QModelIndex& index);
    void onCustomContextMenuRequested(const QPoint&);
    void onRefresh();
    void onRemove(const QString&);
    void onMore(const QStringList&);
    void onSwitchViewType(ViewType type);
    void onPaste(const QStringList& srcs, const QString& dst, bool move);

};
